package com.bjsxt.controller;

import java.util.Set;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.GatewayApiDefinitionManager;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;

/**
 * 测试验证 网关路由配置信息
 * 
 * @author michael
 * @date 2021/06/22
 * @version 1.0
 * @Copyright Copyright (c) 2021, michael.xie@adsnova.cn All Rights Reserved. 
 */
@RestController
public class GatewayFlowRulesController {

    
    /**
     * 获取当前系统的限流策略
     */
    @GetMapping("/gw/flow/rules")
    public Set<GatewayFlowRule> getCurrentGatewayRules() {
        
        return GatewayRuleManager.getRules();
    }
    
    /**
     * 获取自定义的API分组
     */
    @GetMapping("/gw/api/groups")
    public Set<ApiDefinition> getApiGroups() {
        
        return GatewayApiDefinitionManager.getApiDefinitions();
    }
    
}
